/*
 * Amkai Enterprise (AE.) 
 * Copyright 2004-2006 by Amkai(TM), Inc.
 * www.amkai.com
 * 
 * Project: webservice
 * Package: com.amkai.aes.webservice.binary.objecthandler
 * File: PersonInsuranceInfoHandler.java
 * Created: Oct 2, 2006 4:14:09 PM
 * Author: lkovari 
 * 
 */
package com.amkai.aes.webservice.binary.objecthandler;

import java.io.Serializable;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.amkai.aes.aescommon.CommonSettings;
import com.amkai.aes.aescommon.service.scheduling.SchedulingJob;
import com.amkai.aes.aescommon.service.scheduling.SchedulingResult;
import com.amkai.aes.server.scheduling.SchedulingJobHandler;
import com.amkai.aes.server.scheduling.old.SchedulingProvider;
import com.amkai.aes.webservice.binary.JobObjectHandler;

public class SchedulingHandler implements JobObjectHandler<SchedulingJob, Serializable, SchedulingResult> {

	private static final Log log = LogFactory.getLog(SchedulingHandler.class);

	
	public SchedulingResult process(SchedulingJob job, Serializable object) throws Exception {
		SchedulingResult result = null;
		try {
			if(CommonSettings.USE_FAST_SCHEDULING){
				SchedulingJobHandler sjh = new SchedulingJobHandler();
				result = sjh.processJob(job, object);
			}else{
				SchedulingProvider sp = new SchedulingProvider();
				result = sp.processJob(job, object);
				
				if(result == null){
					SchedulingJobHandler sjh = new SchedulingJobHandler();
					result = sjh.processJob(job, object);					
				}
			}
		} catch (Throwable e) {
			log.error("",e );
			throw new Exception(e);
		}
		return result;
	}

}
